<template>
	<view>
		<!-- prize_type  1积分  2红包  3商品 -->
		<!-- amount_type  1积分  2积分 -->
			<view  v-for="(item,index2) in listInfo" :key="index2">
				<navigator class="List flexBox" :url="'../../prizeD?lid='+item.id">
				<view class="labelIco">
					<image src="/static/images/label.png" mode=""></image>
					<view class="activity" v-if="item.activity_type==1">大转盘</view>
					<view class="activity" v-if="item.activity_type==2">九宫格</view>
					<view class="activity" v-if="item.activity_type==3">刮刮乐</view>
				</view>
				<view class="ImgBox"><image  :src="item.icon" mode=""></image></view>
				<view class="InfoBox">
					<view class=" flexBox2">
						<view class="Name">
							<text v-if="item.prize_type==1">{{item.amount}}积分</text>
							<text v-if="item.prize_type==2">
								<text  v-if="item.amount_type==1">{{item.amount}}积分红包</text>
								<text  v-if="item.amount_type==2">{{item.amount}}积分红包</text>
							</text>
							<text v-if="item.prize_type==3">{{item.goods_name}}</text>
							<text v-if="item.prize_type==4">{{item.amount}}优惠券</text>
						</view>
						<view v-if="item.prize_type==3&&!item.shipping_code&&item.shipping_express_id==0" class="state" style="color: red;"> 待发货</view>
						<view v-if="item.prize_type==3&&item.shipping_code&&item.shipping_express_id!=0" class="state" style="color: #09BB07;"> 已发货</view>
						
					</view>
					<view class="flexBox2">
						<view class="Time">
							中奖时间：{{item.addtime}}
						</view>
						<view class="addBtn" v-if="item.prize_type==3&&!item.shipping_code&&item.shipping_express_id==0" @click.stop="addBtn(item.id)">
							{{!item.send_info?'选择地址':'修改地址'}}
						</view>
							<view v-if="item.prize_type==3&&item.shipping_code&&item.shipping_express_id!=0" class="addBtn" @click.stop="logistics(item.id)">查看物流</view>
					</view>
				</view>
			</navigator>
			</view>
		
		<view class="IfNull" v-if="listInfo.length<=0">
				暂无中将记录
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listInfo:"",
				curpage:1,
				lid:"",
				aid:""
			}
		},
		created() {
			this.getList();
		},
	onReachBottom(e) {
		
			if(this.curpage){
				this.getList(true)
			}else{
				uni.showToast({
					title:"到底了哦~~",
					icon:"none"
				})
			}
		
		
	},
		onLoad(e) {
			if(e.lid&&e.aid){
				this.lid=e.lid;
				this.aid=e.aid;
				this.setadderss();
			}
		},
		methods: {
			logistics(id){//查看物流
				uni.navigateTo({
					url:'/plug/logistics/info?lid='+id
				})
			},
			addBtn(id){//填写发货地址
				uni.navigateTo({
					url:"/member/address/list?lid="+id
				})			
			},
			setadderss(){//设置收货地址
				this.$util.request({
					url: '/mobile/index.php?act=bigwheel&op=sendinfo_save',
					method: 'post',
					data: {
						lid:this.lid,
						aid:this.aid,
					},
				}).then((res)=> {
					if(res.error_code==0){
						uni.showToast({
							title:"设置成功",
							icon:"none"
						})
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
				})
			},
			
			
			getList(state){
			let that = this;
				this.$util.request({				
					url: '/mobile/index.php?act=bigwheel&op=my_prize',
					method: 'get',
					data: {
						curpage:this.curpage
					},
				}).then((res)=> {
					if(state){
						this.listInfo=this.listInfo.concat(res.datas.list) 
					}else{
						this.listInfo=res.datas.list
					}
					if(res.datas.paged.hasmore){
						this.curpage++;
					}else{
						this.curpage=false;
					}
				})
			},
		}
	}
</script>

<style>
	.activity{
		position: absolute;
		top: 0;
		width: 85rpx;
		line-height: 35rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		margin-top: -2rpx;
		text-align: center;
	}
	.labelIco{
		position: relative;
		position: absolute;
		top: 0;
		left: -5rpx;
	}
	.labelIco image{
		width: 95rpx;
		height: 35rpx;
		position: absolute;
		top: 0;
	}
	.addBtn{
		border: 1rpx solid #d4237a;
		color: #d4237a;
		padding: 0 10rpx;
		border-radius: 10rpx;
		line-height: 34rpx;
		margin-left: 30rpx;
	}
	.IfNull{
		font-size: 32rpx;
		text-align: center;
		font-weight: bold;
		}
	.flexBox{
		display: flex;
		align-items: center;
	}
	.flexBox2{
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.List{
		position: relative;
		background-color: #FFFFFF;
		margin: 20rpx;
		padding:40rpx 20rpx 20rpx;
		border-radius: 20rpx;
	}
	.List .Name{
		font-size: 32rpx;
		color: #333333;
	}
	.List .Time{
		font-size: 26rpx;
		color: #999999;
	}
	.List .ImgBox image{
		width: 100rpx;
		height: 100rpx;
		margin-right: 20rpx;
		border-radius: 50%;
		margin-left: 30rpx;
	}
	.state{
		font-size: 26rpx;
		margin-top: -50rpx;
		margin-right: 20rpx;
	}
</style>
